﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Updator
{
    public class Logger
    {
        public Logger()
        {

        }

        public Logger(string path)
        {
            Logpath = path;
        }

        private string Logpath = string.Empty;

        public void Log(string content)
        {
            string logfolderpath = Directory.GetParent(Logpath).FullName;
            if (!Directory.Exists(logfolderpath))
            {
                Directory.CreateDirectory(logfolderpath);
            }
            if (!File.Exists(Logpath))
            {
                FileStream fs = new FileStream(Logpath, FileMode.Create, FileAccess.Write);
                fs.Close();
            }

            try
            {
                FileStream fs = new FileStream(Logpath, FileMode.Append, FileAccess.Write);
                StreamWriter sw = new StreamWriter(fs);
                sw.WriteLine(content);
                sw.Close();
                fs.Close();
            }
            catch (Exception)
            {

            }


        }
    }
}
